{extend name="layout/main" /}

{block name="header"}

{/block}

{block name="content"}
<section class="panel">
    <header class="panel-heading">
        <h4>商品列表</h4>
    </header>
    <div class="panel-body" style="padding-bottom: 50px">
        <form class="form-horizontal" action="{:url('shop/index')}">
            <div class="form-group">
                <div class="col-xs-3">
                    <select name="type" class="form-control">
                        <option value="0">全部分类</option>
                        {foreach $cate as $item}
                        <option {if $Request.get.type == $item->category_id}selected{/if} value="{$item->category_id}">{$item->category_title}</option>
                        {/foreach}
                    </select>
                </div>
                <button type="submit" class="btn btn-color">搜索</button>
                <a type="button" href="{:url('/admin/shop/create')}" class="btn btn-info">添加商品</a>
            </div>
        </form>
        <table class="table table-bordered table-striped no-margin">
            <thead>
            <tr>
                <th class="text-center">ID</th>
                <th class="text-center">标题</th>
                <th class="text-center">分类</th>
                <th class="text-center">内容</th>
                <th class="text-center">状态</th>
                <th class="text-center">库存</th>
                <th class="text-center">价格</th>
                <th class="text-center">排序(数字越小，排到最前面)</th>
                <th class="text-center">创建时间</th>
                <th class="text-center">操作</th>
            </tr>
            </thead>
            <tbody>
            {if !empty($goodsLists)}
            {foreach $goodsLists as $entity}
            <tr>
                <td class="text-center">{$entity->id}</td>
                <td class="text-center">{$entity->goods_title}</td>
                <td class="text-center">{$categoryModel->getParentByCategoryId($entity->category_id)}</td>

                <!--<td class="text-center"></td>-->
                <td class="text-center">
                    <a onclick="showContent(this)" data-content='{:htmlspecialchars_decode($entity->goods_content)}' class="btn btn-xs btn-primary">查看</a>
                </td>
                <td class="text-center">
                    {if $entity->status == '1'}
                    <a class="btn btn-xs btn-primary">已发布</a>
                    {else /}
                    <a class="btn btn-xs btn-warning">未发布</a>
                    {/if}
                </td>
                <td class="text-center">{$entity->goods_num}</td>
                <td class="text-center">{$entity->goods_prices}</td>
                <td class="text-center">{$entity->sort}</td>
                <td class="text-center"><?php echo date("Y-m-d H:i:s",$entity->addtime);?></td>
                <td class="text-center">
                    <a href="{:url('shop/edit',['id'=>$entity->id])}" class="btn btn-xs btn-info">编辑</a>
                    <a data-url="{:url('shop/delete',['id'=>$entity->id])}" onclick="main.ajaxDelete(this)"
                       data-msg="确定要删除该商品吗？" class="btn btn-xs btn-danger">删除</a>
                </td>
            </tr>
            {/foreach}
            {else /}
            <tr class="text-center">
                <td colspan="5">暂无数据</td>
            </tr>
            {/if}
            </tbody>
        </table>
        <div class="page">
            {:htmlspecialchars_decode($goodsLists->render())}
        </div>
    </div>
</section>
{/block}


{block name="footer"}
    <script>
        function showContent(e){
            $.dialog({
                title: '商品内容',
                content: $(e).attr('data-content')
            });
        }
    </script>
{/block}